/*
 * @Author: asushiye
 * @Date: 2020-07-03 08:51:09
 * @Commit: file content
 */
import { Injectable } from '@angular/core';
import { AfMessageService, gw_code_g } from '@core';
import { _HttpClient } from '@delon/theme';
import { Observable } from 'rxjs';

@Injectable({
  providedIn: 'root'
})
export class ExcelQueueService {
  constructor(
    private http: _HttpClient,
    private msg: AfMessageService
  ) {}

  public get httpClient(): _HttpClient {
    return this.http;
  }

  // 查询上传队列
  public query(queueId: number, fileName: string, business: string): Observable<any> {
    return this.http.get(`${gw_code_g}/excel/queue/query?&queueId=${queueId}&business=${business}&fileName=${fileName}`);
  }

  public getQueryUrl() {
    return `${gw_code_g}/excel/queue/query`;
  }

  // 查询列历史上传队列
  public queryHistory(fileName: string, business: string): Observable<any> {
    return this.http.get(`${gw_code_g}/excel/queue/history/query?business=${business}&fileName=${fileName}`);
  }

  // 归档到历史表中
  public archive(id: any): Observable<any> {
    return this.http.get(`${gw_code_g}/excel/queue/archive/${id}`);
  }
  // 删除历史表中
  public delete(id: any): Observable<any> {
    return this.http.get(`${gw_code_g}/excel/queue/delete/${id}`);
  }

  // 下载文件
  public downloadFile(queueId: any) {
    window.open(`${gw_code_g}/excel/queue/download?queueId=${queueId}`);
  }

  public getExcelLogUrl() {
    return `${gw_code_g}/excel/upload/log/query`;
  }
}
